<?php
class Form_Category extends Zend_Form {
	public function __construct($id = null, $action = null, $item = null)
	{
		parent::__construct();
        $this->setName("category");
        $this->setAttrib("id", $this->getName());
        if($action === null){
        	$action = 'add';
        	$value = "Добавить";
        } else{
        	$value = "Редактировать";
        }
        if($id === null){
        	$this->setAction("/category/$action/");
        } else {
        	$this->setAction("/category/$action/id/" . $id);
        }
        if($item!=null){
        	$this->setAction($this->getAction() . '/item/'. $item);
        }

        $name = new Zend_Form_Element_Text(
		'name', 
        array('label' => 'Имя категории:','required'=> true));
        $name->addFilter("StripTags");
        $name->addFilter("StringTrim");
        $this->addElement($name);
        
        $parent = new Zend_Form_Element_Hidden('parent', array('value'=>$id));
        //$this->addElement($parent);
        
        $submit = new Zend_Form_Element_Submit('submit',array('label' => $value));
        $this->addElement($submit);
	}
}